package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 服务库存入库流水记录
 * </p>
 *
 * @author linan
 * @date 2022-09-23
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ServiceInventoryInFlowInStockTypeEnum", description = "入库类型 #{ SERVICE_FINISH:服务结束入库;SERVICE_REFUND:服务退款入库;CHECK:盘点入库;OTHER:其他入库;INIT:初始入库;ORDER_CANCEL:订单取消入库;REPAIR:维修入库;RETURN:归还入库-枚举")
public enum ServiceInventoryInFlowInStockTypeEnum implements BaseEnum {

    /**
     * SERVICE_FINISH="服务结束入库"
     */
    SERVICE_FINISH("服务结束入库"),
    /**
     * SERVICE_REFUND="服务退款入库"
     */
    SERVICE_REFUND("服务退款入库"),
    /**
     * CHECK="盘点入库"
     */
    CHECK("盘点入库"),
    /**
     * OTHER="其他入库"
     */
    OTHER("其他入库"),
    /**
     * INIT="初始入库"
     */
    INIT("初始入库"),
    /**
     * ORDER_CANCEL="订单取消入库"
     */
    ORDER_CANCEL("订单取消入库"),
    /**
     * REPAIR="维修入库"
     */
    REPAIR("维修入库"),
    /**
     * RETURN="归还入库"
     */
    RETURN("归还入库"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ServiceInventoryInFlowInStockTypeEnum match(String val, ServiceInventoryInFlowInStockTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ServiceInventoryInFlowInStockTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ServiceInventoryInFlowInStockTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "SERVICE_FINISH,SERVICE_REFUND,CHECK,OTHER,INIT,ORDER_CANCEL,REPAIR,RETURN", example = "SERVICE_FINISH")
    public String getCode() {
        return this.name();
    }

}
